﻿@model IEnumerable<YouFoodIncBDD.FoodsCategory>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
<fieldset>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
@using (Ajax.BeginForm("ListSubCategory", "Category", new AjaxOptions{
                                            UpdateTargetId = "result",
                                            InsertionMode = InsertionMode.Replace,
                                            HttpMethod = "GET",
                                            LoadingElementId = "progress",
                                        }))
{
<table>
    <tr>
        <th>Nom</th>
        <th>Image</th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
           @Ajax.ActionLink(item.name, "ListSubCategory",  new AjaxOptions {
                                                            UpdateTargetId = "result",
                                                            InsertionMode = InsertionMode.Replace,
                                                            HttpMethod = "GET",
                                                            Url= "Category/ListSubCategory?id="+ item.ID
                                                            })
        </td>
        <td>
            <img src="~\@item.image_url" alt="@item.name" />
        </td>
        <td>
            @Html.ActionLink("Edit", "EditCategory", new { id = item.ID }) |
            @Html.ActionLink("Delete", "DeleteCategory", new { id = item.ID })
        </td>
    </tr>
}

</table>
}
<div id="result">

</div>
</fieldset>
